//
//  MBProgressHUB+ShowMessage
//  bleDemo
//
//  Created by wurz on 15/4/12.
//  Copyright (c) 2015年 wurz. All rights reserved.
//

#import "MBProgressHUD+Show.h"

@implementation MBProgressHUD (Show)

#pragma mark 显示一些信息
+ (void)showSuccess:(NSString *)text toView:(UIView *)view duration:(CGFloat)duration {
    if (view == nil) view = [UIApplication sharedApplication].keyWindow;
    // 快速显示一个提示信息
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
    hud.labelText = text;
    
    // 再设置模式
    hud.mode = MBProgressHUDModeText;
    
    // 隐藏时候从父控件中移除
    hud.removeFromSuperViewOnHide = YES;
    
    // YES代表需要蒙版效果
//    hud.dimBackground = YES;
    
    // 1秒之后再消失
    [hud hide:YES afterDelay:duration];
}

+ (void)showError:(NSString *)text toView:(UIView *)view duration:(CGFloat)duration
{
    if (view == nil) view = [UIApplication sharedApplication].keyWindow;
    // 快速显示一个提示信息
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
    hud.labelText = text;
    
    // 再设置模式
    hud.mode = MBProgressHUDModeText;
    
    // 隐藏时候从父控件中移除
    hud.removeFromSuperViewOnHide = YES;
    
    // YES代表需要蒙版效果
//    hud.dimBackground = YES;
    
    // 1秒之后再消失
    [hud hide:YES afterDelay:duration];
}

+ (MBProgressHUD *)showLoading:(NSString *)message toView:(UIView *)view
{
    MBProgressHUD *HUD = [[MBProgressHUD alloc] initWithView:view];
    HUD.labelText = message;
    [view addSubview:HUD];
    [HUD show:YES];
    return HUD;
}

@end
